/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RegistroNeumatico.java
 *
 * Created on 29-abr-2012, 21:45:28
 */
package com.camachosanchez.gui;

import com.camachosanchez.bean.*;
import com.camachosanchez.controler.jdbc.NeumaticosJdbcControler;
import com.camachosanchez.controler.jpa.AlmacenesJpaController;
import com.camachosanchez.controler.jpa.DistribuidoresNeumaticosJpaController;
import com.camachosanchez.controler.jpa.EstadosMedicionJpaController;
import com.camachosanchez.controler.jpa.EstadosNeumaticosJpaController;
import com.camachosanchez.controler.jpa.FormasPagoJpaController;
import com.camachosanchez.controler.jpa.MarcasNeumaticoJpaController;
import com.camachosanchez.controler.jpa.ModelosBandaNeumaticoJpaController;
import com.camachosanchez.controler.jpa.NeumaticosJpaController;
import com.camachosanchez.controler.jpa.TipoPisoJpaController;
import com.camachosanchez.controler.jpa.TiposBandaNeumaticoJpaController;
import com.camachosanchez.gui.textfield.MaxLengthTextDocument;
import com.camachosanchez.util.Constantes;
import com.camachosanchez.util.GUIUtil;
import java.awt.event.KeyEvent;
import java.util.Date;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Rolando
 */
public class RegistroNeumatico extends javax.swing.JDialog {

    /**
     * Creates new form RegistroNeumatico
     */
    public RegistroNeumatico(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        dateFechaCompra.setDate(new Date());
        dateFechaRegistro.setDate(new Date());
        llenarListasDesplegables();
//        setAlwaysOnTop(true);
        MaxLengthTextDocument doc_codigo = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_numserie = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_numfactura = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_codbarras = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_profundidad = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_kilometros = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_profundidad_min = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_presion_min = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_precio = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_garantia_dias = new MaxLengthTextDocument();
        MaxLengthTextDocument doc_garantia_km = new MaxLengthTextDocument();
        doc_codigo.setMaxChars(20, Constantes.ANY);
        doc_numserie.setMaxChars(20, Constantes.ANY);
        doc_numfactura.setMaxChars(20, Constantes.ANY);
        doc_codbarras.setMaxChars(45, Constantes.CADENAS);
        doc_profundidad.setMaxChars(10, Constantes.DECIMALES);
        doc_profundidad_min.setMaxChars(10, Constantes.DECIMALES);
        doc_presion_min.setMaxChars(10, Constantes.DECIMALES);
        doc_precio.setMaxChars(10, Constantes.DECIMALES);
        doc_kilometros.setMaxChars(10, Constantes.ENTEROS);
        doc_garantia_dias.setMaxChars(10, Constantes.ENTEROS);
        doc_garantia_km.setMaxChars(10, Constantes.ENTEROS);
        txtCodigo.setDocument(doc_codigo);
        txtNumeroSerie.setDocument(doc_numserie);
        txtNumeroFactura.setDocument(doc_numfactura);
        txtCodigoBarras.setDocument(doc_codbarras);
        txtPronfundidad.setDocument(doc_profundidad);
        txtProfundadMinima.setDocument(doc_profundidad_min);
        txtPresionMinima.setDocument(doc_presion_min);
        txtPrecio.setDocument(doc_precio);
        txtRecorrido.setDocument(doc_kilometros);
        txtGarantiaDias.setDocument(doc_garantia_dias);
        txtGarantiaKM.setDocument(doc_garantia_km);
        txtPronfundidad.setText("0.0");
        txtProfundadMinima.setText("0.0");
        txtPresionMinima.setText("0.0");
        txtPrecio.setText("0.0");
        txtGarantiaDias.setText("0");
        txtRecorrido.setText("0");
        txtGarantiaKM.setText("0");
        dateFechaRegistro.setMaxSelectableDate(new Date());
        dateFechaCompra.setMaxSelectableDate(new Date());
        pack();
        setLocationRelativeTo(null);
        GUIUtil.addEscapeKey(this);
        setModal(modal);
    }

    private void llenarListasDesplegables() {
        MarcasNeumaticoJpaController dao_marcas = new MarcasNeumaticoJpaController(null);
        AlmacenesJpaController dao_almacenes = new AlmacenesJpaController(null);
        TipoPisoJpaController dao_tipos_piso = new TipoPisoJpaController(null);
        ModelosBandaNeumaticoJpaController dao_bandas = new ModelosBandaNeumaticoJpaController(null);
        DistribuidoresNeumaticosJpaController dao_distribuidores = new DistribuidoresNeumaticosJpaController(null);
        FormasPagoJpaController dao_pagos = new FormasPagoJpaController(null);
        EstadosNeumaticosJpaController dao_estados = new EstadosNeumaticosJpaController(null);
        TiposBandaNeumaticoJpaController dao_tipos_banda = new TiposBandaNeumaticoJpaController(null);
        EstadosMedicionJpaController dao_estadosMedicion = new EstadosMedicionJpaController(null);
        List<MarcasNeumatico> marcas = dao_marcas.findMarcasNeumaticoEntities();
        List<Almacenes> almacenes = dao_almacenes.findAlmacenesEntities();
        List<TipoPiso> tipos_piso = dao_tipos_piso.findTipoPisoEntities();
        List<ModelosBandaNeumatico> bandas = dao_bandas.findModelosBandaNeumaticoEntities();
        List<DistribuidoresNeumaticos> distribuidores = dao_distribuidores.findDistribuidoresNeumaticosEntities();
        List<FormasPago> pagos = dao_pagos.findFormasPagoEntities();
        List<EstadosNeumaticos> estados = dao_estados.findEstadosNeumaticosEntities();
        List<TiposBandaNeumatico> tiposBanda = dao_tipos_banda.findTiposBandaNeumaticoEntities();
        List<EstadosMedicion> estadosMedicion = dao_estadosMedicion.findEstadosMedicionEntities();
        cmbMarcas.setModel(new DefaultComboBoxModel(marcas.toArray()));
        cmbAlmacenes.setModel(new DefaultComboBoxModel(almacenes.toArray()));
        cmbTipoPiso.setModel(new DefaultComboBoxModel(tipos_piso.toArray()));
        cmbMedidas.setModel(new DefaultComboBoxModel(bandas.toArray()));
        cmbTipoBanda.setModel(new DefaultComboBoxModel(tiposBanda.toArray()));
        cmbTipoBandaInicial.setModel(new DefaultComboBoxModel(tiposBanda.toArray()));
        comboDistribuidores.setModel(new DefaultComboBoxModel(distribuidores.toArray()));
        comboFormasPago.setModel(new DefaultComboBoxModel(pagos.toArray()));
        cmbEstadoNeumatico.setModel(new DefaultComboBoxModel(estados.toArray()));
        cmbTipoPisoInicial.setModel(new DefaultComboBoxModel(tipos_piso.toArray()));
        cmbEstadoMedicion.setModel(new DefaultComboBoxModel(estadosMedicion.toArray()));
        Almacenes a = (Almacenes) cmbAlmacenes.getSelectedItem();
        if (a != null) {
            txtDireccionAlmacen.setText(a.getDireccion());
        }
    }

    private void guardarNeumatico() {
        Neumaticos neumatico = new Neumaticos();
        //El neumático va directo a almacén
//        CategoriasJpaController categorias = new CategoriasJpaController(null);
        neumatico.setIdCategoria(new Categorias(1));
        //---------------------------------
        String codigo = txtCodigo.getText().trim();
        String numero_serie = txtNumeroSerie.getText().trim();
        String numero_factura = txtNumeroFactura.getText().trim();
        String codigo_barras = txtCodigoBarras.getText().trim();
        Date fecha_registro = dateFechaRegistro.getDate();
        Date fecha_compra = dateFechaCompra.getDate();
        MarcasNeumatico marca = (MarcasNeumatico) cmbMarcas.getSelectedItem();
        Almacenes almacen = (Almacenes) cmbAlmacenes.getSelectedItem();
        TipoPiso piso = (TipoPiso) cmbTipoPiso.getSelectedItem();
        TipoPiso pisoInicial = (TipoPiso) cmbTipoPisoInicial.getSelectedItem();
        ModelosBandaNeumatico medida = (ModelosBandaNeumatico) cmbMedidas.getSelectedItem();
        TiposBandaNeumatico banda = (TiposBandaNeumatico) cmbTipoBanda.getSelectedItem();
        TiposBandaNeumatico bandaInicial = (TiposBandaNeumatico) cmbTipoBandaInicial.getSelectedItem();
        EstadosMedicion estadoMedicion = (EstadosMedicion) cmbEstadoMedicion.getSelectedItem();
        String _profundidad = txtPronfundidad.getText();
        String renovaciones = spnRenovaciones.getValue().toString();
        String despinches = spnDespinches.getValue().toString();
        String recorrido = txtRecorrido.getText();
        String numero_capas = spnNumeroCapas.getValue().toString();
        String _profundidad_minima = txtProfundadMinima.getText();
        String _presion_minima = txtPresionMinima.getText();
        DistribuidoresNeumaticos distribuidor = (DistribuidoresNeumaticos) comboDistribuidores.getSelectedItem();
        String _precio = txtPrecio.getText();
        FormasPago forma_pago = (FormasPago) comboFormasPago.getSelectedItem();
        String garantia_dias = txtGarantiaDias.getText();
        String garantia_km = txtGarantiaKM.getText();
        String comentarios = txpComentarios.getText();
        if (codigo != null && !codigo.isEmpty() && codigo.length() <= 20) {
            neumatico.setCodigo(codigo);
        } else {
            JOptionPane.showMessageDialog(this, "El código debe tener una longitud máxima de 20 caracteres.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtCodigo.requestFocusInWindow();
            return;
        }
        if (numero_serie != null && !numero_serie.isEmpty() && numero_serie.length() <= 20) {
            neumatico.setNumSerie(numero_serie);
        } else {
            JOptionPane.showMessageDialog(this, "El número de serie debe tener una longitud máxima de 20 caracteres.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtNumeroSerie.requestFocusInWindow();
            return;
        }
        if (codigo_barras.length() <= 45) {
            neumatico.setCodBarras(codigo_barras);
        } else {
            JOptionPane.showMessageDialog(this, "El código de barras debe tener una longitud máxima de 45 caracteres.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtNumeroSerie.requestFocusInWindow();
            return;
        }
        if (numero_factura.length() <= 20) {
            neumatico.setNumFactura(numero_factura);
        } else {
            JOptionPane.showMessageDialog(this, "El número de factura debe tener una longitud máxima de 20 caracteres.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtNumeroSerie.requestFocusInWindow();
            return;
        }
        neumatico.setFechaRegistro(fecha_registro);
        neumatico.setFechaCompra(fecha_compra);
        neumatico.setIdMarca(marca);
        neumatico.setIdAlmacen(almacen);
        neumatico.setTipoPiso(piso);
        neumatico.setIdTipoPisoInicial(pisoInicial);
        neumatico.setIdModelo(medida);
        neumatico.setIdBanda(banda);
        neumatico.setIdBandaInicial(bandaInicial);
        try {
            Double profundidad = Double.parseDouble(_profundidad);
            neumatico.setProfunidad(profundidad);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la profundidad debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtPronfundidad.requestFocusInWindow();
            return;
        }
        try {
            Integer km = Integer.parseInt(recorrido);
            neumatico.setDistanciaRecorrida(km);
            //neumatico.setKmTotal(km);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la distancia recorrida debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtRecorrido.requestFocusInWindow();
            return;
        }
        try {
            Double profundidad_minima = Double.parseDouble(_profundidad_minima);
            neumatico.setProfundidadMinima(profundidad_minima);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la profundidad mínima debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtProfundadMinima.requestFocusInWindow();
            return;
        }
        try {
            Double presion_minima = Double.parseDouble(_presion_minima);
            neumatico.setPresionMinima(presion_minima);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la presión mínima debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtPresionMinima.requestFocusInWindow();
            return;
        }
        neumatico.setIdDistribuidor(distribuidor);
        try {
            Float precio = Float.parseFloat(_precio);
            neumatico.setPrecio(precio);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para el precio debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtGarantiaKM.requestFocusInWindow();
            return;
        }
        neumatico.setIdFormaPago(forma_pago);
        try {
            Integer g_dias = Integer.parseInt(garantia_dias);
            neumatico.setGarantiaDias(g_dias);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la garantía en días debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtGarantiaDias.requestFocusInWindow();
            return;
        }
        try {
            Integer g_km = Integer.parseInt(garantia_km);
            neumatico.setGarantiaKilometros(g_km);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para la garantía en kilómetros debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            txtGarantiaKM.requestFocusInWindow();
            return;
        }
        try {
            Integer num_reno = Integer.parseInt(renovaciones);
            neumatico.setNumRenovaciones(num_reno);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para el número de renovaciones debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            spnRenovaciones.requestFocusInWindow();
            return;
        }
        
        try {
            Integer num_despinches = Integer.parseInt(despinches);
            neumatico.setNumDespinches(num_despinches);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para el número de despinches debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            spnDespinches.requestFocusInWindow();
            return;
        }

        try {
            Integer num_capas = Integer.parseInt(numero_capas);
            neumatico.setNumCapas(num_capas);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para el número de capas debe ser un número.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
            spnNumeroCapas.requestFocusInWindow();
            return;
        }
        neumatico.setIdEstado((EstadosNeumaticos) cmbEstadoNeumatico.getSelectedItem());
        NeumaticosJpaController dao_neumatico = new NeumaticosJpaController(null);
        neumatico.setComentario(comentarios);
//        UsuariosDAOHbn user = new UsuariosDAOHbn();
        neumatico.setIdUsuario(Constantes.currentUser);
        neumatico.setEstado(true);
        neumatico.setFechaInsercionActualizacion(new Date());
        neumatico.setInfMontaje("");
        neumatico.setIdEstadoMedicion(estadoMedicion);
        dao_neumatico.create(neumatico);
        JOptionPane.showMessageDialog(this, Constantes.NEUMATICO_GUARDADO, Constantes.OPERACION_FINALIZADA, JOptionPane.INFORMATION_MESSAGE);
        dispose();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        toolBarPrincipal = new javax.swing.JToolBar();
        pnlToolBar = new javax.swing.JPanel();
        btnNuevo = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        pnlContenedorPrincipal = new javax.swing.JPanel();
        pnlInfirmacionPrincipal = new javax.swing.JPanel();
        lblCodigo = new javax.swing.JLabel();
        txtCodigo = new javax.swing.JTextField();
        lblNumeroSerie = new javax.swing.JLabel();
        txtNumeroSerie = new javax.swing.JTextField();
        lblNumeroFactura = new javax.swing.JLabel();
        txtNumeroFactura = new javax.swing.JTextField();
        lblCodigoBarras = new javax.swing.JLabel();
        txtCodigoBarras = new javax.swing.JTextField();
        lblFechaRegistro = new javax.swing.JLabel();
        dateFechaRegistro = new com.toedter.calendar.JDateChooser();
        lblEstadoNuematico = new javax.swing.JLabel();
        cmbEstadoNeumatico = new javax.swing.JComboBox();
        panelInfo = new javax.swing.JPanel();
        pnlTecnica = new javax.swing.JPanel();
        lblMarca = new javax.swing.JLabel();
        pnlMarca = new javax.swing.JPanel();
        cmbMarcas = new javax.swing.JComboBox();
        lblTipoPiso = new javax.swing.JLabel();
        pnlTipoPiso = new javax.swing.JPanel();
        cmbTipoPiso = new javax.swing.JComboBox();
        lblBandas = new javax.swing.JLabel();
        pnlMedida = new javax.swing.JPanel();
        cmbMedidas = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        pnlTipoBanda = new javax.swing.JPanel();
        cmbTipoBanda = new javax.swing.JComboBox();
        pnlAlamcenamiento = new javax.swing.JPanel();
        lblEstadoMedicion = new javax.swing.JLabel();
        cmbEstadoMedicion = new javax.swing.JComboBox();
        lblAlmacen = new javax.swing.JLabel();
        pnlAlmacen = new javax.swing.JPanel();
        cmbAlmacenes = new javax.swing.JComboBox();
        lblDireccionAlmacen = new javax.swing.JLabel();
        txtDireccionAlmacen = new javax.swing.JTextField();
        lblFechaCompra = new javax.swing.JLabel();
        dateFechaCompra = new com.toedter.calendar.JDateChooser();
        tbpInformacionAdicional = new javax.swing.JTabbedPane();
        pnlInformacionInicial = new javax.swing.JPanel();
        pnlInformacionInicialDatos = new javax.swing.JPanel();
        lblProfundidad = new javax.swing.JLabel();
        txtPronfundidad = new javax.swing.JTextField();
        lblRenovaciones = new javax.swing.JLabel();
        spnRenovaciones = new javax.swing.JSpinner();
        lblRecorrido = new javax.swing.JLabel();
        txtRecorrido = new javax.swing.JTextField();
        lblNumeroCapas = new javax.swing.JLabel();
        spnNumeroCapas = new javax.swing.JSpinner();
        lblProfunidadMinima = new javax.swing.JLabel();
        txtProfundadMinima = new javax.swing.JTextField();
        lblPresionMinima = new javax.swing.JLabel();
        txtPresionMinima = new javax.swing.JTextField();
        lblBandas1 = new javax.swing.JLabel();
        cmbTipoBandaInicial = new javax.swing.JComboBox();
        lblPisos = new javax.swing.JLabel();
        cmbTipoPisoInicial = new javax.swing.JComboBox();
        lblRecorrido1 = new javax.swing.JLabel();
        spnDespinches = new javax.swing.JSpinner();
        pnlDistribuidorCostosGarantia = new javax.swing.JPanel();
        lblDistribuidor = new javax.swing.JLabel();
        lblPrecio = new javax.swing.JLabel();
        txtPrecio = new javax.swing.JTextField();
        lblFormaPago = new javax.swing.JLabel();
        comboFormasPago = new javax.swing.JComboBox();
        lblGarantiaDias = new javax.swing.JLabel();
        txtGarantiaDias = new javax.swing.JTextField();
        lblGarantiaKM = new javax.swing.JLabel();
        txtGarantiaKM = new javax.swing.JTextField();
        comboDistribuidores = new javax.swing.JComboBox();
        pnlComentarios = new javax.swing.JPanel();
        scrComentarios = new javax.swing.JScrollPane();
        txpComentarios = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(".:: Registro de Neumáticos ::.");
        setResizable(false);

        toolBarPrincipal.setBackground(new java.awt.Color(204, 204, 255));
        toolBarPrincipal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        toolBarPrincipal.setFloatable(false);
        toolBarPrincipal.setRollover(true);
        toolBarPrincipal.setOpaque(false);

        pnlToolBar.setBackground(new java.awt.Color(255, 255, 255));
        pnlToolBar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        btnNuevo.setBackground(new java.awt.Color(255, 204, 102));
        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/camachosanchez/recursos/24_new.png"))); // NOI18N
        btnNuevo.setToolTipText("Nuevo");
        btnNuevo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnNuevo.setFocusable(false);
        btnNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnNuevo.setMaximumSize(new java.awt.Dimension(22, 22));
        btnNuevo.setMinimumSize(new java.awt.Dimension(22, 22));
        btnNuevo.setPreferredSize(new java.awt.Dimension(22, 22));
        btnNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });
        pnlToolBar.add(btnNuevo);

        btnGuardar.setBackground(new java.awt.Color(255, 204, 102));
        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/camachosanchez/recursos/24_save.png"))); // NOI18N
        btnGuardar.setToolTipText("Guardar");
        btnGuardar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnGuardar.setFocusable(false);
        btnGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnGuardar.setMaximumSize(new java.awt.Dimension(22, 22));
        btnGuardar.setMinimumSize(new java.awt.Dimension(22, 22));
        btnGuardar.setPreferredSize(new java.awt.Dimension(22, 22));
        btnGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        pnlToolBar.add(btnGuardar);

        toolBarPrincipal.add(pnlToolBar);

        getContentPane().add(toolBarPrincipal, java.awt.BorderLayout.PAGE_START);

        pnlContenedorPrincipal.setOpaque(false);

        pnlInfirmacionPrincipal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información Principal", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        pnlInfirmacionPrincipal.setOpaque(false);
        pnlInfirmacionPrincipal.setLayout(new java.awt.GridLayout(3, 4, 5, 5));

        lblCodigo.setText("<html>Código: <font color=\"red\">(*)</font> </html>");
        pnlInfirmacionPrincipal.add(lblCodigo);

        txtCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCodigoKeyPressed(evt);
            }
        });
        pnlInfirmacionPrincipal.add(txtCodigo);

        lblNumeroSerie.setText("<html>Número de serie: <font color=\"red\">(*)</font> </html>");
        pnlInfirmacionPrincipal.add(lblNumeroSerie);

        txtNumeroSerie.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNumeroSerieKeyPressed(evt);
            }
        });
        pnlInfirmacionPrincipal.add(txtNumeroSerie);

        lblNumeroFactura.setText("Número de factura:");
        pnlInfirmacionPrincipal.add(lblNumeroFactura);

        txtNumeroFactura.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNumeroFacturaKeyPressed(evt);
            }
        });
        pnlInfirmacionPrincipal.add(txtNumeroFactura);

        lblCodigoBarras.setText("Código de barras:");
        pnlInfirmacionPrincipal.add(lblCodigoBarras);

        txtCodigoBarras.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCodigoBarrasKeyPressed(evt);
            }
        });
        pnlInfirmacionPrincipal.add(txtCodigoBarras);

        lblFechaRegistro.setText("Fecha de registro:");
        pnlInfirmacionPrincipal.add(lblFechaRegistro);

        dateFechaRegistro.setDateFormatString("dd/MM/yyyy");
        dateFechaRegistro.setOpaque(false);
        pnlInfirmacionPrincipal.add(dateFechaRegistro);

        lblEstadoNuematico.setText("Estado del neumático:");
        pnlInfirmacionPrincipal.add(lblEstadoNuematico);

        cmbEstadoNeumatico.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbEstadoNeumatico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbEstadoNeumaticoKeyPressed(evt);
            }
        });
        pnlInfirmacionPrincipal.add(cmbEstadoNeumatico);

        panelInfo.setOpaque(false);
        panelInfo.setLayout(new java.awt.GridLayout(1, 0));

        pnlTecnica.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información Técnica", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        pnlTecnica.setOpaque(false);
        pnlTecnica.setLayout(new java.awt.GridLayout(4, 2, 0, 2));

        lblMarca.setText("Marca:");
        pnlTecnica.add(lblMarca);

        pnlMarca.setOpaque(false);
        pnlMarca.setLayout(new java.awt.BorderLayout(5, 0));

        cmbMarcas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbMarcas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbMarcasKeyPressed(evt);
            }
        });
        pnlMarca.add(cmbMarcas, java.awt.BorderLayout.CENTER);

        pnlTecnica.add(pnlMarca);

        lblTipoPiso.setText("Tipo de piso:");
        pnlTecnica.add(lblTipoPiso);

        pnlTipoPiso.setOpaque(false);
        pnlTipoPiso.setLayout(new java.awt.BorderLayout(5, 0));

        cmbTipoPiso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbTipoPiso.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbTipoPisoKeyPressed(evt);
            }
        });
        pnlTipoPiso.add(cmbTipoPiso, java.awt.BorderLayout.CENTER);

        pnlTecnica.add(pnlTipoPiso);

        lblBandas.setText("<html>Medida: <font color=\"red\">(*)</font> </html>");
        pnlTecnica.add(lblBandas);

        pnlMedida.setOpaque(false);
        pnlMedida.setLayout(new java.awt.BorderLayout(5, 0));

        cmbMedidas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbMedidas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbMedidasKeyPressed(evt);
            }
        });
        pnlMedida.add(cmbMedidas, java.awt.BorderLayout.CENTER);

        pnlTecnica.add(pnlMedida);

        jLabel1.setText("Tipo de banda:");
        pnlTecnica.add(jLabel1);

        pnlTipoBanda.setLayout(new java.awt.BorderLayout());

        cmbTipoBanda.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbTipoBanda.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbTipoBandaKeyPressed(evt);
            }
        });
        pnlTipoBanda.add(cmbTipoBanda, java.awt.BorderLayout.CENTER);

        pnlTecnica.add(pnlTipoBanda);

        panelInfo.add(pnlTecnica);

        pnlAlamcenamiento.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información de Almacenamiento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        pnlAlamcenamiento.setOpaque(false);

        lblEstadoMedicion.setText("Estado de medición:");

        cmbEstadoMedicion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lblAlmacen.setText("Almacen:");

        pnlAlmacen.setOpaque(false);
        pnlAlmacen.setPreferredSize(new java.awt.Dimension(149, 20));
        pnlAlmacen.setLayout(new java.awt.BorderLayout(5, 0));

        cmbAlmacenes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbAlmacenes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbAlmacenesActionPerformed(evt);
            }
        });
        cmbAlmacenes.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbAlmacenesKeyPressed(evt);
            }
        });
        pnlAlmacen.add(cmbAlmacenes, java.awt.BorderLayout.CENTER);

        lblDireccionAlmacen.setText("Dirección:");

        txtDireccionAlmacen.setEditable(false);
        txtDireccionAlmacen.setFont(new java.awt.Font("Tahoma", 0, 10));

        lblFechaCompra.setText("Fecha de compra:");

        dateFechaCompra.setDateFormatString("dd/MM/yyyy");
        dateFechaCompra.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                dateFechaCompraKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout pnlAlamcenamientoLayout = new javax.swing.GroupLayout(pnlAlamcenamiento);
        pnlAlamcenamiento.setLayout(pnlAlamcenamientoLayout);
        pnlAlamcenamientoLayout.setHorizontalGroup(
            pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAlamcenamientoLayout.createSequentialGroup()
                .addComponent(lblEstadoMedicion, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(cmbEstadoMedicion, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(pnlAlamcenamientoLayout.createSequentialGroup()
                .addComponent(lblAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(pnlAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(pnlAlamcenamientoLayout.createSequentialGroup()
                .addComponent(lblDireccionAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(txtDireccionAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(pnlAlamcenamientoLayout.createSequentialGroup()
                .addComponent(lblFechaCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(dateFechaCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlAlamcenamientoLayout.setVerticalGroup(
            pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAlamcenamientoLayout.createSequentialGroup()
                .addGroup(pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblEstadoMedicion, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbEstadoMedicion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblDireccionAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDireccionAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(pnlAlamcenamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblFechaCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateFechaCompra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        panelInfo.add(pnlAlamcenamiento);

        tbpInformacionAdicional.setBackground(new java.awt.Color(188, 211, 226));

        pnlInformacionInicialDatos.setLayout(new java.awt.GridLayout(3, 6, 2, 8));

        lblProfundidad.setText("Profundidad (mm):");
        pnlInformacionInicialDatos.add(lblProfundidad);

        txtPronfundidad.setText("0.0");
        txtPronfundidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtPronfundidadKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(txtPronfundidad);

        lblRenovaciones.setText("N° de Reencauches:");
        pnlInformacionInicialDatos.add(lblRenovaciones);

        spnRenovaciones.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                spnRenovacionesKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(spnRenovaciones);

        lblRecorrido.setText("Recorrido (km):");
        pnlInformacionInicialDatos.add(lblRecorrido);

        txtRecorrido.setText("0");
        txtRecorrido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtRecorridoKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(txtRecorrido);

        lblNumeroCapas.setText("Número de capas:");
        pnlInformacionInicialDatos.add(lblNumeroCapas);

        spnNumeroCapas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                spnNumeroCapasKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(spnNumeroCapas);

        lblProfunidadMinima.setText("Profundidad mínima:");
        pnlInformacionInicialDatos.add(lblProfunidadMinima);

        txtProfundadMinima.setText("0.0");
        txtProfundadMinima.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtProfundadMinimaKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(txtProfundadMinima);

        lblPresionMinima.setText("Presion mínima (lb):");
        pnlInformacionInicialDatos.add(lblPresionMinima);

        txtPresionMinima.setText("0.0");
        txtPresionMinima.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtPresionMinimaKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(txtPresionMinima);

        lblBandas1.setText("Tipo de banda:");
        pnlInformacionInicialDatos.add(lblBandas1);

        cmbTipoBandaInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbTipoBandaInicial.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbTipoBandaInicialKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(cmbTipoBandaInicial);

        lblPisos.setText("Tipo de piso:");
        pnlInformacionInicialDatos.add(lblPisos);

        cmbTipoPisoInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbTipoPisoInicial.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbTipoPisoInicialKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(cmbTipoPisoInicial);

        lblRecorrido1.setText("N° de Despinches:");
        pnlInformacionInicialDatos.add(lblRecorrido1);

        spnDespinches.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                spnDespinchesKeyPressed(evt);
            }
        });
        pnlInformacionInicialDatos.add(spnDespinches);

        javax.swing.GroupLayout pnlInformacionInicialLayout = new javax.swing.GroupLayout(pnlInformacionInicial);
        pnlInformacionInicial.setLayout(pnlInformacionInicialLayout);
        pnlInformacionInicialLayout.setHorizontalGroup(
            pnlInformacionInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlInformacionInicialLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlInformacionInicialDatos, javax.swing.GroupLayout.DEFAULT_SIZE, 683, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlInformacionInicialLayout.setVerticalGroup(
            pnlInformacionInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlInformacionInicialLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlInformacionInicialDatos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        tbpInformacionAdicional.addTab("Información Inicial", pnlInformacionInicial);

        lblDistribuidor.setText("Distribuidor:");

        lblPrecio.setText("Precio:");

        txtPrecio.setText("0.0");
        txtPrecio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtPrecioKeyPressed(evt);
            }
        });

        lblFormaPago.setText("Forma de pago:");

        comboFormasPago.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        comboFormasPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                comboFormasPagoKeyPressed(evt);
            }
        });

        lblGarantiaDias.setText("Garantía (días):");

        txtGarantiaDias.setText("0");
        txtGarantiaDias.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtGarantiaDiasKeyPressed(evt);
            }
        });

        lblGarantiaKM.setText("Garantía (km):");

        txtGarantiaKM.setText("0");

        comboDistribuidores.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        comboDistribuidores.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                comboDistribuidoresKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout pnlDistribuidorCostosGarantiaLayout = new javax.swing.GroupLayout(pnlDistribuidorCostosGarantia);
        pnlDistribuidorCostosGarantia.setLayout(pnlDistribuidorCostosGarantiaLayout);
        pnlDistribuidorCostosGarantiaLayout.setHorizontalGroup(
            pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDistribuidorCostosGarantiaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlDistribuidorCostosGarantiaLayout.createSequentialGroup()
                        .addComponent(lblDistribuidor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboDistribuidores, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlDistribuidorCostosGarantiaLayout.createSequentialGroup()
                        .addComponent(lblFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboFormasPago, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblGarantiaDias, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtGarantiaDias)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblPrecio)
                    .addComponent(lblGarantiaKM, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtPrecio, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                    .addComponent(txtGarantiaKM, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE))
                .addContainerGap())
        );

        pnlDistribuidorCostosGarantiaLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lblDistribuidor, lblFormaPago});

        pnlDistribuidorCostosGarantiaLayout.setVerticalGroup(
            pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDistribuidorCostosGarantiaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lblDistribuidor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(comboDistribuidores)
                        .addComponent(lblPrecio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(txtPrecio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDistribuidorCostosGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboFormasPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtGarantiaKM, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblGarantiaDias)
                    .addComponent(txtGarantiaDias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblGarantiaKM)
                    .addComponent(lblFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        pnlDistribuidorCostosGarantiaLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblDistribuidor, lblFormaPago});

        tbpInformacionAdicional.addTab("Distribuidor, Costos y Garantía", pnlDistribuidorCostosGarantia);

        pnlComentarios.setLayout(new java.awt.BorderLayout());

        scrComentarios.setBorder(null);

        txpComentarios.setBorder(null);
        scrComentarios.setViewportView(txpComentarios);

        pnlComentarios.add(scrComentarios, java.awt.BorderLayout.CENTER);

        tbpInformacionAdicional.addTab("Comentarios", pnlComentarios);

        javax.swing.GroupLayout pnlContenedorPrincipalLayout = new javax.swing.GroupLayout(pnlContenedorPrincipal);
        pnlContenedorPrincipal.setLayout(pnlContenedorPrincipalLayout);
        pnlContenedorPrincipalLayout.setHorizontalGroup(
            pnlContenedorPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlContenedorPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlContenedorPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tbpInformacionAdicional, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(panelInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
                    .addComponent(pnlInfirmacionPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlContenedorPrincipalLayout.setVerticalGroup(
            pnlContenedorPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlContenedorPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlInfirmacionPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addComponent(panelInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tbpInformacionAdicional, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(pnlContenedorPrincipal, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
// TODO add your handling code here:
    NeumaticosJdbcControler daoJdbc = new NeumaticosJdbcControler();
    if (!daoJdbc.existeNeumatico(txtCodigo.getText().trim())) {
        if (txtCodigo.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, Constantes.CODIGO_NEUMATICO_REQUERIDO, Constantes.DATOS_INCOMPLETOS, JOptionPane.WARNING_MESSAGE);
            txtCodigo.requestFocusInWindow();
            return;
        }
        if (txtNumeroSerie.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, Constantes.SERIE_NEUMATICO_REQUERIDO, Constantes.DATOS_INCOMPLETOS, JOptionPane.WARNING_MESSAGE);
            txtNumeroSerie.requestFocusInWindow();
            return;
        }
        if (cmbAlmacenes.getSelectedItem() == null) {
            JOptionPane.showMessageDialog(this, "Seleccione un almacén para el neumático. Si no existe uno, ingréselo desde el menú Logística.", "Datos incompletos", JOptionPane.WARNING_MESSAGE);
            cmbAlmacenes.requestFocusInWindow();
            return;
        }
        if (cmbMedidas.getSelectedItem() == null) {
            JOptionPane.showMessageDialog(this, "Seleccione una medida para el neumático. Si no existe uno, ingréselo desde el menú Logística.", "Datos incompletos", JOptionPane.WARNING_MESSAGE);
            cmbMedidas.requestFocusInWindow();
            return;
        }
        guardarNeumatico();
    } else {
        JOptionPane.showMessageDialog(this, "Ya existe un neumático registrado con el código indicado.", "Datos incorrectos", JOptionPane.WARNING_MESSAGE);
        txtCodigo.requestFocusInWindow();
    }
}//GEN-LAST:event_btnGuardarActionPerformed

private void txtCodigoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoKeyPressed
// TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        txtNumeroSerie.requestFocusInWindow();
    }
}//GEN-LAST:event_txtCodigoKeyPressed

private void txtNumeroSerieKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumeroSerieKeyPressed
// TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        txtNumeroFactura.requestFocusInWindow();
    }
}//GEN-LAST:event_txtNumeroSerieKeyPressed

private void txtNumeroFacturaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumeroFacturaKeyPressed
// TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        txtCodigoBarras.requestFocusInWindow();
    }
}//GEN-LAST:event_txtNumeroFacturaKeyPressed

private void txtCodigoBarrasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoBarrasKeyPressed
// TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        dateFechaRegistro.requestFocusInWindow();
    }
}//GEN-LAST:event_txtCodigoBarrasKeyPressed

    private void cmbMarcasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbMarcasKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbTipoPiso.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbMarcasKeyPressed

    private void cmbTipoPisoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbTipoPisoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbMedidas.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbTipoPisoKeyPressed

    private void cmbMedidasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbMedidasKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbTipoBanda.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbMedidasKeyPressed

    private void cmbAlmacenesKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbAlmacenesKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            dateFechaCompra.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbAlmacenesKeyPressed

    private void dateFechaCompraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateFechaCompraKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtPronfundidad.requestFocusInWindow();
        }
    }//GEN-LAST:event_dateFechaCompraKeyPressed

    private void spnRenovacionesKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_spnRenovacionesKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtRecorrido.requestFocusInWindow();
        }
    }//GEN-LAST:event_spnRenovacionesKeyPressed

    private void txtPronfundidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPronfundidadKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            spnRenovaciones.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtPronfundidadKeyPressed

    private void txtRecorridoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRecorridoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            spnNumeroCapas.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtRecorridoKeyPressed

    private void spnNumeroCapasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_spnNumeroCapasKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtProfundadMinima.requestFocusInWindow();
        }
    }//GEN-LAST:event_spnNumeroCapasKeyPressed

    private void txtProfundadMinimaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtProfundadMinimaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtPresionMinima.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtProfundadMinimaKeyPressed

    private void comboDistribuidoresKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_comboDistribuidoresKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtPrecio.requestFocusInWindow();
        }
    }//GEN-LAST:event_comboDistribuidoresKeyPressed

    private void txtPrecioKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPrecioKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            comboFormasPago.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtPrecioKeyPressed

    private void comboFormasPagoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_comboFormasPagoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtGarantiaDias.requestFocusInWindow();
        }
    }//GEN-LAST:event_comboFormasPagoKeyPressed

    private void txtGarantiaDiasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtGarantiaDiasKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            txtGarantiaKM.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtGarantiaDiasKeyPressed

    private void cmbEstadoNeumaticoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbEstadoNeumaticoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbMarcas.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbEstadoNeumaticoKeyPressed

private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
// TODO add your handling code here:
    nuevo();
}//GEN-LAST:event_btnNuevoActionPerformed

private void cmbAlmacenesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbAlmacenesActionPerformed
// TODO add your handling code here:
    Almacenes a = (Almacenes) cmbAlmacenes.getSelectedItem();
    if (a != null) {
        txtDireccionAlmacen.setText(a.getDireccion());
    }
}//GEN-LAST:event_cmbAlmacenesActionPerformed

    private void cmbTipoBandaInicialKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbTipoBandaInicialKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbTipoPisoInicial.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbTipoBandaInicialKeyPressed

    private void txtPresionMinimaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPresionMinimaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbTipoBandaInicial.requestFocusInWindow();
        }
    }//GEN-LAST:event_txtPresionMinimaKeyPressed

    private void spnDespinchesKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_spnDespinchesKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_spnDespinchesKeyPressed

    private void cmbTipoBandaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbTipoBandaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            cmbAlmacenes.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbTipoBandaKeyPressed

    private void cmbTipoPisoInicialKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbTipoPisoInicialKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            spnDespinches.requestFocusInWindow();
        }
    }//GEN-LAST:event_cmbTipoPisoInicialKeyPressed

    private void nuevo() {
        GUIUtil.limpiarVentana(pnlInfirmacionPrincipal.getComponents());
        GUIUtil.limpiarVentana(pnlTecnica.getComponents());
        GUIUtil.limpiarVentana(pnlAlamcenamiento.getComponents());
        GUIUtil.limpiarVentana(pnlComentarios.getComponents());
        GUIUtil.limpiarVentana(pnlDistribuidorCostosGarantia.getComponents());
        txtPronfundidad.setText("0.0");
        txtProfundadMinima.setText("0.0");
        txtPresionMinima.setText("0.0");
        txtPrecio.setText("0.0");
        txtRecorrido.setText("0");
        txtGarantiaDias.setText("0");
        txtGarantiaKM.setText("0");
        txtCodigo.requestFocusInWindow();
        Almacenes a = (Almacenes) cmbAlmacenes.getSelectedItem();
        if (a != null) {
            txtDireccionAlmacen.setText(a.getDireccion());
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JComboBox cmbAlmacenes;
    private javax.swing.JComboBox cmbEstadoMedicion;
    private javax.swing.JComboBox cmbEstadoNeumatico;
    private javax.swing.JComboBox cmbMarcas;
    private javax.swing.JComboBox cmbMedidas;
    private javax.swing.JComboBox cmbTipoBanda;
    private javax.swing.JComboBox cmbTipoBandaInicial;
    private javax.swing.JComboBox cmbTipoPiso;
    private javax.swing.JComboBox cmbTipoPisoInicial;
    private javax.swing.JComboBox comboDistribuidores;
    private javax.swing.JComboBox comboFormasPago;
    private com.toedter.calendar.JDateChooser dateFechaCompra;
    private com.toedter.calendar.JDateChooser dateFechaRegistro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lblAlmacen;
    private javax.swing.JLabel lblBandas;
    private javax.swing.JLabel lblBandas1;
    private javax.swing.JLabel lblCodigo;
    private javax.swing.JLabel lblCodigoBarras;
    private javax.swing.JLabel lblDireccionAlmacen;
    private javax.swing.JLabel lblDistribuidor;
    private javax.swing.JLabel lblEstadoMedicion;
    private javax.swing.JLabel lblEstadoNuematico;
    private javax.swing.JLabel lblFechaCompra;
    private javax.swing.JLabel lblFechaRegistro;
    private javax.swing.JLabel lblFormaPago;
    private javax.swing.JLabel lblGarantiaDias;
    private javax.swing.JLabel lblGarantiaKM;
    private javax.swing.JLabel lblMarca;
    private javax.swing.JLabel lblNumeroCapas;
    private javax.swing.JLabel lblNumeroFactura;
    private javax.swing.JLabel lblNumeroSerie;
    private javax.swing.JLabel lblPisos;
    private javax.swing.JLabel lblPrecio;
    private javax.swing.JLabel lblPresionMinima;
    private javax.swing.JLabel lblProfundidad;
    private javax.swing.JLabel lblProfunidadMinima;
    private javax.swing.JLabel lblRecorrido;
    private javax.swing.JLabel lblRecorrido1;
    private javax.swing.JLabel lblRenovaciones;
    private javax.swing.JLabel lblTipoPiso;
    private javax.swing.JPanel panelInfo;
    private javax.swing.JPanel pnlAlamcenamiento;
    private javax.swing.JPanel pnlAlmacen;
    private javax.swing.JPanel pnlComentarios;
    private javax.swing.JPanel pnlContenedorPrincipal;
    private javax.swing.JPanel pnlDistribuidorCostosGarantia;
    private javax.swing.JPanel pnlInfirmacionPrincipal;
    private javax.swing.JPanel pnlInformacionInicial;
    private javax.swing.JPanel pnlInformacionInicialDatos;
    private javax.swing.JPanel pnlMarca;
    private javax.swing.JPanel pnlMedida;
    private javax.swing.JPanel pnlTecnica;
    private javax.swing.JPanel pnlTipoBanda;
    private javax.swing.JPanel pnlTipoPiso;
    private javax.swing.JPanel pnlToolBar;
    private javax.swing.JScrollPane scrComentarios;
    private javax.swing.JSpinner spnDespinches;
    private javax.swing.JSpinner spnNumeroCapas;
    private javax.swing.JSpinner spnRenovaciones;
    private javax.swing.JTabbedPane tbpInformacionAdicional;
    private javax.swing.JToolBar toolBarPrincipal;
    private javax.swing.JTextPane txpComentarios;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtCodigoBarras;
    private javax.swing.JTextField txtDireccionAlmacen;
    private javax.swing.JTextField txtGarantiaDias;
    private javax.swing.JTextField txtGarantiaKM;
    private javax.swing.JTextField txtNumeroFactura;
    private javax.swing.JTextField txtNumeroSerie;
    private javax.swing.JTextField txtPrecio;
    private javax.swing.JTextField txtPresionMinima;
    private javax.swing.JTextField txtProfundadMinima;
    private javax.swing.JTextField txtPronfundidad;
    private javax.swing.JTextField txtRecorrido;
    // End of variables declaration//GEN-END:variables
}
